package com.wang.sort;

public class Demo8_EvenTimeOddTimes {
    //arr中只有一种数出现奇数次
    public static void printOddTimesNum1(int[] arr){
        int eor = 0;
        for (int i = 0; i < arr.length; i++) {
            eor ^= arr[i];
        }
        System.out.println(eor);
    }
    //arr中有两种数出现奇数次
    public static void printOddTimesNum2(int[] arr){
        int eor = 0;
        for (int i = 0; i < arr.length; i++) {
            eor ^= arr[i];
        }
        int rightOne = eor & (~eor + 1);
        int onlyOne = 0;
        for (int i = 0; i < arr.length; i++) {
            onlyOne ^= arr[i];
        }
        System.out.println(onlyOne + "" + (eor ^ onlyOne));
    }

}
